package tech.aistar.corejava.day12.dayhomeork;

import java.util.*;

/**
 * Created by Administrator on 2019/7/30.
 */
public class HashSetWork {
    public static void main(String[] args) {
        Set<Product> pro = new HashSet<>();
        Product p1 = new Product(1, "小米", 10.00, "河南");
        Product p6 = new Product(6, "小米", 10.00, "河南");
        Product p2 = new Product(2, "大米", 10.00, "河南");
        Product p3 = new Product(3, "绿豆", 20.00, "河南");
        Product p4 = new Product(4, "劳斯莱斯魅影", 3000000.00, "劳斯莱斯汽车公司");
        Product p7 = new Product(7, "劳斯莱斯魅影", 3000000.00, "劳斯莱斯汽车公司");
        Product p5 = new Product(5, "劳斯莱斯魅影星空版", 5000000.00, "劳斯莱斯汽车公司");

        pro.add(p1);
        pro.add(p2);
        pro.add(p3);
        pro.add(p4);
        pro.add(p5);
        pro.add(p6);
        pro.add(p7);
       System.out.println(pro);
       System.out.println("===========================");


        Iterator<Product> iter = pro.iterator();
        System.out.println(pro);

        List<Product> pro1 = new ArrayList<>();

        while (iter.hasNext()){
            Product p = iter.next();
            if (p.getPrice()>300){
                pro1.add(p);
            }
        }
        System.out.println(pro1);
    }
}
